﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfShopLogistics.aspx.cs" Inherits="msBsc.WebUi.wfShopLogistics" %>

<!DOCTYPE HTML>
<html>
<head id="Head1" runat="server">
    <title>物流模版管理</title>
    <link rel="shortcut icon" href="/themes/Style1/Image/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/??themes/Style1/StyleQt.css,themes/Style1/address.css,themes/Style1/sel.css" />
    <script src="/??jqPlugin/js/jquery-1.8.3.min.js,js/jBase.js,js/jBPage.js,themes/Style1/jsQt.js,jqPlugin/js/laytpl.js,jqPlugin/layer/layer.min.js,jqPlugin/layer/extend/layer.ext.js"
        type="text/javascript"></script>
    <!--head fix rgn-->
    <script type="text/javascript">
        $(window).load(function () {
            $("#dplSelectTemplate").change(function () {
                loadlist();
            });
            setAllValiInp();

//            $("#txtTEMPLATE_NME").change(function () {
//                var _jsParam = new jsonRow();
//                _jsParam.AddCell("ACTION", "doAddNew");
//                _jsParam.AddCell("ID", $("#txtLOGISTICS_TEMPLATE_ID").val());
//                _jsParam.AddCell("TEMP_NME", $("#txtTEMPLATE_NME").val());
//                ajaxComm(_jsParam);
//            });
        });

        $(function () {
            $("#zonelistshow li").live("click", function () { if ($(this).hasClass("tb-out-of-stock")) { return; } if ($(this).hasClass("tb-selected")) { $(this).removeClass("tb-selected") } else { $(this).addClass("tb-selected"); } });

            $(".thead-tbl-address").live("mouseover", function () { $(this).addClass("address-hover").find(".implicit").removeClass("hide"); }).live("mouseout", function () { $(this).removeClass("address-hover").find(".implicit").removeClass("hide").addClass("hide"); });
        });
        function getZoneSelForSave(_jsPost) {
            var $list1 = $('#zonelistshow .tb-selected');
            $list1.each(function (i, Item) {
                _jsPost.AddCell("PROVINCE_ID" + i, $(this).attr('data-value'));
                _jsPost.AddCell("PROVINCE_NME" + i, $(this).attr('data-nme'));
            });
            _jsPost.AddCell("ZONE_COUNT", $list1.length);
        };
        function doSave() {
            if (getAllValiInp()) {
                var _jsParam = new jsonRow();
                var _jsPost = new jsonRow();
                GetFormJson("J_FormBox", _jsPost);
                _jsParam.AddCell("ACTION", "doSave");
                getZoneSelForSave(_jsPost);
                _jsPost.AddCell("OLD_ZONE_TITLE", $("#txtZoneTitle").val());
                _jsPost.AddCell("LOGISTICS_TEMPLATE_ID", $("#dplSelectTemplate").val());
                ajaxComm(_jsParam, _jsPost, function () { layer.close(layerform); });
            }
        };

        function loadlist() {
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "loadlist");
            _jsParam.AddCell("TEMP_ID", $("#dplSelectTemplate").val());
            ajaxComm(_jsParam);
        };
        function doAddNew(sId) {
            $("#txtZoneTitle").val('');
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "doAddNew");
            _jsParam.AddCell("TEMP_ID", $("#dplSelectTemplate").val());
            ajaxComm(_jsParam);
            ShowForm();
        };
        function doedit(sztitle) {
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "doedit");
            _jsParam.AddCell("TEMP_ID", $("#dplSelectTemplate").val());
            _jsParam.AddCell("ZONE_TITLE", sztitle);
            ajaxComm(_jsParam); 
            ShowForm();
        };
        function dodelete(sztitle) {
            if (!confirm('您确认要删除吗？')) {return;}
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "dodelete");
            _jsParam.AddCell("TEMP_ID", $("#dplSelectTemplate").val());
            _jsParam.AddCell("ZONE_TITLE", sztitle);
            ajaxComm(_jsParam);
        };
        function dodeleteTemp() {
            if (!confirm('您确认要删除吗？')) { return; }
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "dodeleteTemp");
            _jsParam.AddCell("TEMP_ID", $("#dplSelectTemplate").val()); 
            ajaxComm(_jsParam);
        };
//        function dosetdefault(sId) {
//            var _jsParam = new jsonRow();
//            _jsParam.AddCell("ACTION", "dosetdefault");
//            _jsParam.AddCell("ID", sId);
//            ajaxComm(_jsParam);
//        }; 
        var layerform;
        function ShowForm() {
            layerform && layer.close(layerform);
            layerform=$.layer({
                type: 1,
                shade: [0],
                fix: true,
                title: '输入运价信息',
                maxmin: false,
                page: { dom: '#J_FormBox' },
                area: ['630px', '430px']
            });
        };

        function doAddNewTemp() {
            layer.prompt({ title: '输入新模版的名字？' }, function (name) {
                var _jsParam = new jsonRow();
                _jsParam.AddCell("ACTION", "doAddNewTemp");
                _jsParam.AddCell("TEMPLATE_NME", name);
                ajaxComm(_jsParam);
            });
        };
    </script> 
</head>
<body>
    <div id="mallPage" class="tms-page mallAct tmall-  page-not-market">
        <!-- -->
        <!--商城通用顶通-->
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderTopHtml()%>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderLogoDealerHtml("商户管理")%>
        <div id="content" class="content" style=" padding-top: 3px;">
            <div class="page lang-zh-S">
                <div id="mytaobao-panel" class="grid-c2">
                    <div class="col-main" id="J_Col_Main" style="padding-bottom: 0;">
                        <div class="bought">
                            <div class="main-wrap">
                                <h2 class="h2-single">
                                    <span class="entity" id="J_DeliverTitle">物流详细信息</span></h2> 
                                <div class="form-box" style="width:auto;">
                                    <div class="item item-title">
                                        <span class="item-label">提示： </span>同一模版名称下2条记录中的地区不能有重复。
                                       <span><button type="button" class="btn" onclick="doAddNewTemp();" style=" margin-top:-5px;">
                                            新增模版</button> </span> 
                                       <span><button type="button" class="btn" onclick="dodeleteTemp();" style=" margin-top:-5px;">
                                            删除模版</button> </span> 
                                    </div>
                                    <div class="item ">
                                        <span class="item-label">模版列表：<i>*</i></span>
                                        <select name="dplSelectTemplate" id="dplSelectTemplate" class="comSel" style="width: 270px; font-size:17px;">
                                        </select>
                                    </div>
                                    </div>
                                <div class="form-box" id="J_FormBox" style="width:auto;display:none;"> 
                                    <div class="item item-title">
                                        <span class="item-label">提示： </span>同一模版下地区不能重复选择。
                                    </div>
                                    <div class="item" >
                                        <span class="item-label">区域标识：<i>*</i></span>
                                        <input class="i-text vali-inp" type="text" id="txtZONE_TITLE" value=""   reg-exp="^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_]){2,15}$" right-msg="允许2-16个字符，可用中文、数字、字母、下划线"/>
                                    </div>
                                    <div class="item ">
                                        <span class="item-label">选择地区：<i>*</i></span>
                                        <div  class="ks-combobox-input-wrap">
                                        
                                                    <dl class="tb-prop tm-clear">
                                                        <dd>
                                                            <ul class="tm-clear J_TSaleProp" id="zonelistshow">
                                                            </ul>
                                                        </dd>
                                                    </dl>
                                        </div>
                                    </div>
                                    <div class="item " >
                                        <span class="item-label">运费设定：</span>
                                        <input class="i-text i-text-short" id="txtQTY_FIRST" type="text" value="" style="width:50px;"/>
                                        件内，
                                        <input class="i-text i-text-short" id="txtPRICE_FIRST" type="text" value=""  style="width:50px;"/>
                                        元，每增加
                                        <input class="i-text i-text-short" id="txtQTY_ADD" type="text" value=""  style="width:50px;"/>
                                        件，增加运费
                                        <input class="i-text i-text-short" id="txtPRICE_ADD" type="text" value=""  style="width:50px;"/>
                                        元
                                    </div> 
                                    <div class="item"> 
                                        <button type="button" class="btn" onclick="doSave();" style=" margin-left:10px;">
                                            保存</button>
                                    </div>
                                    <input id="txtZoneTitle" type="text" value="" style="display: none;" /> 
                                </div>
                                <h2 class="h2-single">
                                    <span class="entity"  >各区域运价列表</span><button type="button" class="btn" onclick="doAddNew();" style=" margin-top:-5px;">
                                            新增区域运价</button></h2> 
                                <div class="tbl-deliver-address"> 
                                    <div id="loadlist">
                                    </div> 
                                </div>
                            </div>
                            <span class="mytaobao-rc-bt"><span></span></span>
                        </div>
                    </div>
                    <!-- end col-main -->
                    <div class="col-sub" id="J_Col_Sub">
                        <%=new msBsc.WebUi.Code.QtHtmlGet().GetDealerMenu()%>
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <!-- end mytaobao-panel -->
            </div>
        </div>
        <!-- template -->
        <textarea id="zone_list_temp" style="display:none;">  
            {{# for(var i = 0, len = d.rows.length; i < len; i++){ }}
            <li data-value="{{ d.rows[i].PROVINCE_ID }}" data-nme="{{ d.rows[i].PROVINCE_NME }}" class="{{# if(d.rows[i].IS_CHECKED=='True'){ }} tb-selected {{# }else{ }}   {{#}}} {{# if(d.rows[i].ALLOW_CHECKED!='True'){ }} tb-out-of-stock {{#}}}"><a href="javascript:void(0);"><span>{{ d.rows[i].PROVINCE_NME }}</span></a><i>已选中</i></li>
            {{# } }}                             
        </textarea>
        <textarea id="list_temp" style="display: none;">  
        
        <table border="0" cellspacing="0" cellpadding="0" class="tbl-main">
            <colgroup>
                <col class="col-area">
                <col class="col-address">
                <col class="col-man">
                <col class="col-area">
                <col class="col-postcode">
                <col class="col-phone">
                <col class="col-actions">
            </colgroup>
            <tbody >
            <tr class="thead-tbl-grade">
                <th>
                    区域标识
                </th>
                <th>
                    送达地区集合
                </th>
                <th >
                    初始件数
                </th>
                <th >
                    初始费用
                </th>
                <th >
                    增加件数
                </th>
                <th >
                    增加费用
                </th>
                <th >
                    操作
                </th>
            </tr>   
            {{# for(var i = 0, len = d.rows.length; i < len; i++){ }}
            <tr class="thead-tbl-address ">
                <td >
                    {{ d.rows[i].ZONE_TITLE }}
                </td>
                <td >
                    {{ d.rows[i].ZONE_DESC }}
                </td>
                <td>
                    {{ d.rows[i].QTY_FIRST }}
                </td>
                <td>
                    {{ d.rows[i].PRICE_FIRST }}
                </td>
                <td>
                     {{ d.rows[i].QTY_ADD }}
                </td>
                <td>
                      {{ d.rows[i].PRICE_ADD }}
                </td>
                <td>
                    <a href="javascript:void(0);" onclick="doedit('{{ d.rows[i].ZONE_TITLE }}');">修改</a> | <a href="javascript:void(0);"  onclick="dodelete('{{ d.rows[i].ZONE_TITLE }}');" class="del">删除</a>
                </td>
            </tr> 
            {{# } }}      
                </tbody>
            </table>
        </textarea>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetFloorHtml()%>
    </div>
    <!-- foot script -->
</body>
</html>
